Skip to content

Add baggage support#1659

Open
siri-varma wants to merge 12 commits intodapr:masterfrom
siri-varma:users/svegiraju/add-baggage
Open

Add baggage support#1659
siri-varma wants to merge 12 commits intodapr:masterfrom
siri-varma:users/svegiraju/add-baggage

Conversation

@siri-varma
Copy link
Contributor

Description

Please explain the changes you've made

Issue reference

We strive to have all PR being opened based on an issue, where the problem or feature have been discussed prior to implementation.

Please reference the issue this PR will close: #[issue number]

Checklist

Please make sure you've completed the relevant tasks for this PR, out of the following list:

  • Code compiles correctly
  • Created/updated tests
  • Extended the documentation

@siri-varma siri-varma self-assigned this Feb 20, 2026
@siri-varma siri-varma marked this pull request as ready for review February 28, 2026 21:43
@siri-varma siri-varma requested review from a team as code owners February 28, 2026 21:43
@siri-varma
Copy link
Contributor Author

@artur-ciocanu / @cicoyle / @javier-aliaga / @salaboy Please take a look at this PR when you get a chance. Thanks

@codecov
Copy link

codecov bot commented Mar 4, 2026

Codecov Report

❌ Patch coverage is 86.66667% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 79.54%. Comparing base (a2877aa) to head (6e5bdd9).

Files with missing lines Patch % Lines
...rnal/grpc/interceptors/DaprBaggageInterceptor.java 84.61% 0 Missing and 2 partials ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #1659      +/-   ##
============================================
+ Coverage     79.51%   79.54%   +0.02%     
- Complexity     2194     2196       +2     
============================================
  Files           237      238       +1     
  Lines          6577     6591      +14     
  Branches        730      732       +2     
============================================
+ Hits           5230     5243      +13     
+ Misses          992      990       -2     
- Partials        355      358       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@javier-aliaga javier-aliaga requested a review from Copilot March 4, 2026 16:37
@javier-aliaga
Copy link
Contributor

@siri-varma I ask copilot to review, lets see what it suggest, I will do my own review tomorrow

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds W3C baggage propagation support to the Dapr Java SDK so that baggage can flow through both gRPC and HTTP calls via Reactor context, and includes a new example + gRPC-focused tests.

Changes:

  • Add Headers.BAGGAGE constant and propagate it through HTTP header allowlist.
  • Introduce DaprBaggageInterceptor and wire it into the gRPC interceptor chain.
  • Add a baggage example and a new gRPC unit test suite validating propagation behavior.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
sdk/src/test/java/io/dapr/client/DaprClientGrpcBaggageTest.java New gRPC tests validating baggage propagation behavior.
sdk/src/main/java/io/dapr/internal/grpc/interceptors/DaprBaggageInterceptor.java New gRPC client interceptor injecting baggage into metadata from Reactor context.
sdk/src/main/java/io/dapr/internal/grpc/DaprClientGrpcInterceptors.java Wires the new baggage interceptor into the existing interceptor chain.
sdk/src/main/java/io/dapr/client/Headers.java Adds a public BAGGAGE header constant.
sdk/src/main/java/io/dapr/client/DaprHttp.java Allows baggage to be promoted from Reactor context into outgoing HTTP headers.
examples/src/main/java/io/dapr/examples/baggage/README.md New documentation for the baggage example.
examples/src/main/java/io/dapr/examples/baggage/BaggageClient.java New runnable example demonstrating baggage propagation via Reactor context.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +59 to +61
@AfterEach
public void tearDown() {
}
Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This @AfterEach method is empty, so it adds noise without providing cleanup. Consider removing it or using it to clean up resources created in setupServer (for example, shutting down the ManagedChannel if not handled by GrpcCleanupRule).

Copilot uses AI. Check for mistakes.
Comment on lines +74 to +76
Mono<Void> result = invoke()
.contextWrite(it -> it.putAll((ContextView) context));
result.block();
Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The cast to ContextView is unnecessary here since Reactor's Context already implements ContextView. Using putAll(context) directly avoids the cast and matches existing patterns in other tests.

Copilot uses AI. Check for mistakes.
Comment on lines +91 to +93
Mono<Void> result = invoke()
.contextWrite(it -> it.putAll((ContextView) context));
result.block();
Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The cast to ContextView is unnecessary here since Reactor's Context already implements ContextView. Using putAll(context) directly avoids the cast and matches existing patterns in other tests.

Copilot uses AI. Check for mistakes.
Comment on lines +109 to +111
Mono<Void> result = invoke()
.contextWrite(it -> it.putAll((ContextView) context));
result.block();
Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The cast to ContextView is unnecessary here since Reactor's Context already implements ContextView. Using putAll(context) directly avoids the cast and matches existing patterns in other tests.

Copilot uses AI. Check for mistakes.
Comment on lines +130 to +132
Mono<Void> result = invoke()
.contextWrite(it -> it.putAll((ContextView) context));
result.block();
Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The cast to ContextView is unnecessary here since Reactor's Context already implements ContextView. Using putAll(context) directly avoids the cast and matches existing patterns in other tests.

Copilot uses AI. Check for mistakes.
Comment on lines +69 to +70
private static final Set<String> ALLOWED_CONTEXT_IN_HEADERS =
Set.of("grpc-trace-bin", "traceparent", "tracestate", "baggage");
Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This adds baggage to the context-to-header allowlist, but there isn't a corresponding HTTP test asserting the header is actually propagated. Consider extending the existing invokeServiceWithContext test (or adding a new one) to put Headers.BAGGAGE in the Reactor context and assert the outgoing HttpRequest contains the baggage header.

Copilot uses AI. Check for mistakes.
import io.dapr.client.DaprClientBuilder;
import io.dapr.client.Headers;
import io.dapr.client.domain.HttpExtension;
import io.dapr.utils.TypeRef;
Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused import io.dapr.utils.TypeRef is present but not referenced in this example. Please remove it to keep the example compiling cleanly under stricter build/lint configurations.

Suggested change
import io.dapr.utils.TypeRef;

Copilot uses AI. Check for mistakes.
.addService(service)
.build().start());

ManagedChannel channel = InProcessChannelBuilder.forName(serverName).directExecutor().build();
Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ManagedChannel created for the in-process server isn't registered with GrpcCleanupRule (and isn't otherwise shut down). This can leak threads/resources across tests; register the channel with grpcCleanup or explicitly shutdown it in an @AfterEach hook.

Suggested change
ManagedChannel channel = InProcessChannelBuilder.forName(serverName).directExecutor().build();
ManagedChannel channel = grpcCleanup.register(
InProcessChannelBuilder.forName(serverName).directExecutor().build());

Copilot uses AI. Check for mistakes.
@siri-varma
Copy link
Contributor Author

@copilot can you fix the comments ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants